Ext.define('TS.view.inv.ProductContactQuery', {
    extend: 'Ext.panel.Panel',
    alias : 'widget.productcontactquery',
	mixins: {
        observable: 'Ext.util.Observable'
    },
    layout:'fit',
    hideBorders: true,
    bodyPadding:0,
    title : '商品出入库流水查询',
    initComponent: function() {
		var invstore=Ext.create('TS.store.base.InvAddsStore');
//		var emptyInvadd = Ext.create('TS.model.base.InvAddModel',{
//			id:0,
//			inventoryAddName:'空',
//			inventoryType:0,
//			defaultInvAdd:false,
//			deptId:0
//		});
		//invstore.insert(0,[emptyInvadd]);
		invstore.add({id:0,inventoryAddName:'空'});
		invstore.load({addRecords: true});
    	Ext.apply(this, {
    		items:[{
    		    xtype: 'panel',
                layout: 'border',
                items:[
	        		{
	        			xtype: 'form',
	        			region:'north',
	        			collapsible :true,
	        			items:[
	        				{
	        					xtype:'fieldset',
						        height:50,
						        title: '选择商品',
						        defaultType:'fieldcontainer',
							    defaults:{
									layout: {
										type:'hbox',//横排布局
										align:'stretch'
									},
									fieldDefaults:{
										readOnly:true,  
										labelAlign:'left',
										labelWidth:60
							    	}
								},
						        items:[
						        	{
						        		items:[
						        			{
						                        name : 'productCode',
						                        fieldLabel: '商品编号',
						                        readOnly:false,
						                        width:160,
						                        allowBlank:false,
						                        xtype: 'triggerfield',
								    	    	emptyText:'请输入商品编码或名称',
								    	    	trigger1Cls:Ext.baseCSSPrefix + "form-search-trigger",
								    	    	onTriggerClick:function(e){
								    	    		e.keyCode=e.ENTER;//设置为Enter事件
								    	    		this.fireEvent('specialkey',this,e);//点客户查询图标执行搜索
								    	    	}
						                    },
							                {
												xtype: 'hiddenfield',
						                        name : 'productId',
						                        fieldLabel: '商品内码'
							                },
							                {
							                	xtype:'textfield',
						                    	name : 'productName',
						                        fieldLabel: '商品名称',
						                        labelAlign:'right',
						                        allowBlank:false,
						                        width:250
						                    },
						                    {
						                    	xtype:'textfield',
						                    	name : 'packSpec',
						                    	width:120,
						                    	labelAlign:'right',
						                    	labelWidth:40,
						                        fieldLabel: '规格'
						                    },
						                    {
						                    	xtype:'textfield',
						                    	name : 'unit',
						                    	width:80,
						                    	labelAlign:'right',
						                    	labelWidth:40,
						                        fieldLabel: '单位'
						                    },
						                    {
						                    	xtype:'textfield',
						                    	name : 'manuf',
						                    	labelAlign:'right',
						                        fieldLabel: '生产企业',
						                        width:300
						                    }
						                    
						        		]
						        	}
						        ]
	        				},
	        				{
	        					xtype:'fieldcontainer',
	        					layout:'hbox',
								items:[
									{
			        					xtype:'fieldset',
			        					
								        height:50,
								        layout: 'hbox',
								        title: '选择批号',
								        items:[
								        	{
												xtype: 'hiddenfield',
						                        name : 'id',
						                        fieldLabel: '批号内码'
						                   	},
						                   	{
						                        name : 'batchNo',
						                        fieldLabel: '批号',
						                        labelWidth:60,
						                        width:210,
						                        readOnly:false,
						                        xtype: 'triggerfield',
								    	    	trigger1Cls:Ext.baseCSSPrefix + "form-search-trigger",
								    	    	onTriggerClick:function(e){
								    	    		e.keyCode=e.ENTER;//设置为Enter事件
								    	    		this.fireEvent('specialkey',this,e);//点客户查询图标执行搜索
								    	    	},
								    	    	listeners: {
								    	    		change:function(field,newValue) {
								    	    			if(newValue == '') {
								    	    				var batchId = field.up().down('hiddenfield[name=id]');
								    	    				batchId.setValue(null);
								    	    			}
								    	    		}
								    	    	}
						                   }
								        ]
			        				},
			        				{
			        					xtype:'fieldset',
			        					height:50,
			        					margin:'0 0 0 10',
			        					title:'选择存货地点',
			        					layout:'hbox',
										fieldDefaults:{
											labelAlign:'right',
											labelWidth:40
								    	},
								    	items:[
									    	{
					    		        		xtype:'combobox',
					    		        		name:'invadd',
					    		        		labelStyle:'text-align:right',
					    		        		fieldLabel: '地点',
					    						queryMode:'local',
					    						valueField:"id",
					    						displayField :'inventoryAddName',
					    						forceSelection:true,
					    						typeAhead : true,
					    						store:invstore								    		
									    	}    
								    	]
			        				},
									{
										xtype:'fieldset',
								        height:50,
								        //width:600,
								        margin:'0 0 0 10',
								        title: '开始期间',
								        layout:'hbox',
										fieldDefaults:{
											labelAlign:'right',
											labelWidth:40
								    	},
								        items:[
							        			{
							                        xtype: 'numberfield',
							                        fieldLabel: '年份',
							                        name:'begYear',
							                        allowDecimals:false,
							                        width:100,
							                        allowBlank: false,
							                        value:new Date().getFullYear(),
							                        minValue:new Date().getFullYear()-5,
							                        maxValue:new Date().getFullYear()+5
							                    },
							        			{
							                        fieldLabel: '期间',
							                        name:'begMonth',
							                        labelSeparator:null,
							                        xtype: 'numberfield',
							                        width:100,
							                        allowDecimals:false,
							                        allowBlank: false,
							                        minValue:1,
							                        value:new Date().getMonth()+1,
							                        maxValue:12
							                    }
							              ]
									},
									{
										xtype:'fieldset',
								        height:50,
								        //width:600,
								        margin:'0 0 0 10',
								        title: '截止期间',
								        layout:'hbox',
										fieldDefaults:{
											labelAlign:'right',
											labelWidth:40
								    	},
										items:[
						                    {
						                        xtype: 'numberfield',
						                        fieldLabel: '年份',
						                        name:'endYear',
						                        allowDecimals:false,
						                        width:100,
						                        allowBlank: false,
						                        value:new Date().getFullYear(),
						                        minValue:new Date().getFullYear()-5,
						                        maxValue:new Date().getFullYear()+5
						                    },
						        			{
						                        fieldLabel: '期间',
						                        name:'endMonth',
						                        xtype: 'numberfield',
						                        width:100,
						                        allowDecimals:false,
						                        allowBlank: false,
						                        minValue:1,
						                        value:new Date().getMonth()+1,
						                        maxValue:12
						                    }	
					                    ]
									},
			                    	{xtype: 'button',text:'查询',margin:'28 10 0 10',action:'searchperiod',iconCls:'bill-find-button'}
								]
	        				}
	        			]
	        		},
	        		Ext.create('TS.view.inv.ProductContactList',{
	        			autoScroll: true,
	        			title:'',
	        			closable: false,
	        			region:'center'       			
	        		})
    			]
    		}]
    	});
        this.callParent(arguments);
    }
});